package com.xmmxjy.common.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * Created by xmm on 2017/3/4.
 */
public class PathUtil implements ServletContextListener {

    private Logger logger = LoggerFactory.getLogger(PathUtil.class);
    //webapp路径
    public static String webappPath = null;
    //class路径
    public static String classPath = Thread.currentThread().getContextClassLoader().getResource("").getPath();

    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        webappPath = servletContextEvent.getServletContext().getRealPath("/");
        logger.info("webappPath : " + webappPath);
        logger.info("classPath : " + classPath);
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }
}
